package com.test.qpbgboot.schedule.controller;

import com.test.qpbgboot.base.response.JsonResult;
import com.test.qpbgboot.schedule.pojo.dto.EscortScheduleQuery;
import com.test.qpbgboot.schedule.pojo.dto.EscortScheduleSaveParam;
import com.test.qpbgboot.schedule.pojo.dto.RoomScheduleQuery;
import com.test.qpbgboot.schedule.pojo.dto.RoomScheduleSaveParam;
import com.test.qpbgboot.schedule.pojo.vo.EscortScheduleVO;
import com.test.qpbgboot.schedule.pojo.vo.RoomScheduleVO;
import com.test.qpbgboot.schedule.service.ScheduleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("/v1/schedule")
@Slf4j
@Api(tags = "schedule module")
public class ScheduleController {

    @Autowired
    private ScheduleService scheduleService;

    @GetMapping("/room/select")
    @ApiOperation(value = "房间排班查询")
    public JsonResult selectRoomSchedule(
            RoomScheduleQuery roomScheduleQuery) {
        log.debug("房间排班查询:roomScheduleQuery={}", roomScheduleQuery);
        List<RoomScheduleVO> roomScheduleVOList = scheduleService
                .roomScheduleSelect(roomScheduleQuery);
        return JsonResult.success(roomScheduleVOList);
    }

    @PostMapping("/room/save")
    @ApiOperation(value = "房间排班保存")
    public JsonResult saveRoomSchedule(
            @Valid @RequestBody RoomScheduleSaveParam roomScheduleSaveParam) {
        log.debug("房间排班保存:roomScheduleSaveParam={}", roomScheduleSaveParam);
        scheduleService.roomScheduleSave(roomScheduleSaveParam);
        return JsonResult.success();
    }

    @GetMapping("/escort/select")
    @ApiOperation(value = "陪玩排班查询")
    public JsonResult selectEscortSchedule(
            EscortScheduleQuery escortScheduleQuery) {
        log.debug("陪玩排班查询:escortScheduleQuery={}", escortScheduleQuery);
        List<EscortScheduleVO> escortScheduleVOList = scheduleService
                .escortScheduleSelect(escortScheduleQuery);
        return JsonResult.success(escortScheduleVOList);
    }

    @PostMapping("/escort/save")
    @ApiOperation(value = "陪玩排班保存")
    public JsonResult saveEscortSchedule(
            @Valid @RequestBody EscortScheduleSaveParam escortScheduleSaveParam) {
        log.debug("陪玩排班保存:escortScheduleSaveParam={}", escortScheduleSaveParam);
        scheduleService.escortScheduleSave(escortScheduleSaveParam);
        return JsonResult.success();
    }
}
